package testsUnitaires;

import java.io.File;
import java.util.ArrayList;

import tools.FileUtils;

import network.KrakenClient;
import network.messages.KrakenClientMsg;
import network.messages.KrakenServerMsg;

public class TestFileTransfert {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayList<String> msgList = new ArrayList<String>();
		msgList.add(KrakenClientMsg.KRAKEN_CLIENT.makeCommand());
		File[] files = FileUtils.listFiles("C:\\Documents and Settings\\Guillaume\\Bureau\\test\\serv1");
		String destination = "C:\\Documents and Settings\\Guillaume\\Bureau\\test\\serv2\\";
		for(File file : files){
			msgList.add(KrakenClientMsg.COPY_FILE.makeCommand(" "+file.getAbsolutePath(), " "+(destination+file.getName())));
		}
		msgList.add(KrakenClientMsg.END_CLIENT.makeCommand());
		
		KrakenClient krakenClient = new KrakenClient(msgList, "localhost");
		krakenClient.connect();
		krakenClient.communicate();
		
		String answer = krakenClient.getFinalAnswer();
		if(answer.equalsIgnoreCase(KrakenServerMsg.END_SERVER.toString())){
			System.out.println("\nTransfert OK!");
		}
	}

}
